//
//  WebCell.m
//  FairyDream
//
//  Created by dllo on 15/8/22.
//  Copyright (c) 2015年 dreams. All rights reserved.
//

#import "WebCell.h"
#import "TravelsModel.h"
#import "UIImageView+WebCache.h"
#define Width 375
@interface WebCell ()

@property (nonatomic, retain) UIImageView *BackImage;
@property (nonatomic, retain) UILabel *titleLable;
@property (nonatomic, retain) UILabel *markLable;

@end


@implementation WebCell

- (void)dealloc
{
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}

- (void)createCell
{
    // 背景图片
    self.BackImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 5, 375, 200 - 5)];
    self.BackImage.backgroundColor = [UIColor clearColor];
    
    [self.contentView addSubview:_BackImage];
    [_BackImage release];
    
    // 标题
    self.titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 85, Width, 30)];
    self.titleLable.backgroundColor = [UIColor clearColor];
    self.titleLable.textAlignment = NSTextAlignmentCenter;
    [self.titleLable setFont:[UIFont fontWithName:@"Al Nile" size:20]];
    self.titleLable.textColor = [UIColor yellowColor];
    [self.contentView addSubview:_titleLable];
    [_titleLable release];
    
    // 标注
    self.markLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 130, Width, 25)];
    self.markLable.backgroundColor = [UIColor clearColor];
    self.markLable.textAlignment = NSTextAlignmentCenter;
    [self.markLable setFont:[UIFont fontWithName:@"Al Nile" size:20]];
    self.markLable.textColor = [UIColor yellowColor];
    [self.contentView addSubview:_markLable];
    [_markLable release];
}

- (void)setModelWithWebCell:(TravelsModel *)model
{
    if ([model.type integerValue] == 5) {
        self.titleLable.text = [NSString stringWithFormat:@"%@", model.cover_title];
        self.markLable.text = [NSString stringWithFormat:@"%@", model.cover_sub_title];
        [self.BackImage sd_setImageWithURL:[NSURL URLWithString:model.app5_cover_url] placeholderImage:nil];
    }
    else if ([model.type integerValue] == 7)
    {
        self.titleLable.text = [NSString stringWithFormat:@"%@", model.title];
        self.markLable.text = [NSString stringWithFormat:@"%@", model.sub_title];
        [self.BackImage sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:nil];
    }
}


@end
